/**
 * Group Page
 */

import expired from '@/config/expired'
import * as cache from '@/util/cache'
import md5 from 'js-md5'
const key = 'GATE' + md5('category')

export default {
  namespaced: true,
  state: {
    cate: null
  },
  getters: {
    cate: state => {
      if (state.cate === null) {
        state.cate = cache.get(key)
      }
      return state.cate
    }
  },
  mutations: {
    SET_DATA: (state, data) => {
      state.cate = data
      cache.save(key, data, expired.categoryExpired)
    }
  },
  actions: {
    set_data: ({ commit }, data) => {
      commit('SET_DATA', data)
    }
  }
}
